﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using Panny.Data;
using System.Data.SqlClient;
using DBUtility;//请先添加引用
namespace Easydp.Models
{
    public class TransferTicketManager
    {
        public DataSet GetDataset(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM TT_TransferTicket ");
            if (!string.IsNullOrEmpty(strWhere))
            {
                strSql.Append(" where  TicketDate>= getdate() and " + strWhere);
            }
            strSql.Append(" order by CreateOn,TicketDate ");
            return DbHelperSQL.Query(strSql.ToString());
        }

        public int Delete(string key)
        {
            string str = string.Format("update TT_TransferTicket set IsDel = 1 where TicketID={0}", key);
            using (SqlText updateion = new SqlText(str))
            {
               return updateion.ExecuteNonQuery();
            }
        }

        public int Insert(Entities.TT_TransferTicket obj)
        {
            int res = 0;
            using (SqlStoredProcedure insertion = new SqlStoredProcedure("Pro_TransferTicket_Pan_Insert"))
            {
                insertion.AddParameter("@LinkMan", obj.Linkman);
                insertion.AddParameter("@Telphone", obj.Telphone);
                insertion.AddParameter("@Email", obj.Email);
                insertion.AddParameter("@FromCity", obj.FromCity);
                insertion.AddParameter("@ToCity", obj.ToCity);
                insertion.AddParameter("@TicketNumber", obj.TicketNumber);
                insertion.AddParameter("@TicketType", obj.TicketType);
                insertion.AddParameter("@TicketDate", obj.TicketDate);
                insertion.AddParameter("@Amount", obj.Amount);
                insertion.AddParameter("@IsCHD", obj.IsCHD);

                insertion.ExecuteNonQuery();

                res = insertion.SelectIdentity();
            }
            return res;
        }

    }
}
